import 'package:flutter/material.dart';

/**
 * StatelessWidget 生命周期
 *
 * 每次调用setState只会调用build
 */
class StatelessDemo extends StatelessWidget {
  final String? title;

  StatelessDemo({super.key, required this.title}) {
    print('构造函数被调用了！');
  }

  @override
  Widget build(BuildContext context) {
    print('build方法被调用了！');
    return Scaffold(
      appBar: AppBar(
        title: Text('StatelessWidget'),
        centerTitle: true,
      ),
      body: Center(
        child: Text(title ?? '123'),
      ),
    );
  }
}
